package ar.com.vates.ejercicio2;

public class Contenedor {
	private Integer numero;
	private boolean disponible=false;

	public synchronized void setNumber(int valor){
		while(disponible==true){
			try{
				wait();
			}catch(InterruptedException e){
				
			}
		}
		this.numero = valor;
		disponible=true;
		notify();
		
		System.out.println(Thread.currentThread().toString() + ": "+ this.numero);
	}
	public synchronized void deleteNumber(){
		while(disponible==false){
			try{
				wait();
			}catch(InterruptedException e){
				
			}
		}
		this.disponible = false;
		notify();
		this.numero=null;		
		System.out.println(Thread.currentThread().toString()+ ": "+ this.numero);
		
	}
}
